package gameobjects;

import org.newdawn.slick.*;

public class Metak {
	
	private Image metak;
	private Color boja;
	private float metakX;
	private float metakY;
	private int smer;
	private boolean raketa;
	
	public Metak () {
		smer = 0;
		raketa = false;
	}
	
	public void setMetak(Image metak) {
		this.metak = metak;
	}
	public Image getMetak() {
		return metak;
	}
	public void setBoja(Color boja) {
		this.boja = boja;
	}
	public Color getBoja() {
		return boja;
	}
	public void setMetakX(float metakX) {
		this.metakX = metakX;
	}
	public float getMetakX() {
		return metakX;
	}
	public void setMetakY(float metakY) {
		this.metakY = metakY;
	}
	public float getMetakY() {
		return metakY;
	}
	public void setSmer(int smer) {
		this.smer = smer;
	}
	public int getSmer() {
		return smer;
	}
	
	public boolean isRaketa() {
		return raketa;
	}
	public void setRaketa(boolean raketa) {
		this.raketa = raketa;
	}
	public void crtaj (Graphics g) {
		if (raketa) {
			metak.draw(metakX, metakY);
		}
		else {
			Color stara = g.getColor();
			g.setColor(boja);
			g.fillRect(metakX, metakY, 6, 6);
			g.setColor(stara);
		}
	}
	
	public void pomerajMetka (float delta) {
		if (smer == 3)//levo
			metakX -= 4 * delta * .1f;
		else if (smer == 2)//desno
			metakX += 4 * delta * .1f;
		else if (smer == 1)//gore
			metakY -= 4 * delta * .1f;
		else if (smer == 0)//dole
			metakY += 4 * delta * .1f;
		else if (smer == 4){//desno-dole
			metakX += 4 * delta * .1f;
			metakY += 4 * delta * .1f;
		}
		else if (smer == 5){//desno-gore
			metakX += 4 * delta * .1f;
			metakY -= 4 * delta * .1f;
		}
		else if (smer == 6){//gore-levo
			metakX -= 4 * delta * .1f;
			metakY -= 4 * delta * .1f;
		}
		else if (smer == 7){//dole-levo
			metakX -= 4 * delta * .1f;
			metakY += 4 * delta * .1f;							
		}
	}
}
